package com.algrithom.chafen;

public class Solution1 {
    
    public static void main(String[] args){
        int[][] bookings = new int[][]{{1,2,10},{2,3,20},{2,5,25}};
        Solution1 solution1 = new Solution1();
        System.out.println(solution1.corpFlightBookings(bookings,5));
    }
    
    public int[] corpFlightBookings(int[][] bookings,int n){
        int[] nums = new int[n];
        for (int[] booking : bookings) {
            nums[booking[0] - 1] += booking[2];
            if (booking[1] < n) {
                nums[booking[1]] -= booking[2];
            }
        }
        for (int i = 1; i < n; i++) {
            nums[i] += nums[i - 1];
        }
        return nums;
    }
}